from socket import *

listenIp   = '127.0.0.1'
listenPort = 12346

targetNetwork = '255.255.255.255'
targetPort    = '12345'

updRecvSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  
updRecvSock.bind(('', listenPort))

sendSock = socket(AF_INET, SOCK_DGRAM)
sendSock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sendSock.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
#s.bind(('', listenPort))
  
while True:  
    data, addr = updRecvSock.recvfrom(2048)  
    if not data:  
        print "client has exist"  
        break  
    print "received:", data, "from", addr
    sendSock.sendto(data, (targetNetwork, targetPort))

updRecvSock.close()  
